<template>
  <div>
    <el-select v-model="selectedStatus" placeholder="请选择" :clearable="clearable" @change="handleChange">

      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  name: 'SelectedStatus',
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    options: {
      type: Array,
      default: () => []
    },
    clearable: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      selectedStatus: ''
      /* options: [
        {
          value: '',
          label: '全部'
        },
        {
          value: 1,
          label: '显示'
        },
        {
          value: 0,
          label: '隐藏'
        }
      ] */
    }
  },
  watch: {
    value(newValue) {
      this.selectedStatus = newValue
    },
    /* selectedStatus(newValue) {
      this.$emit('change', newValue)
    } */
  },
  methods: {
    handleChange(value) {
      this.selectedStatus = value
      console.log(value)
      this.$emit('input', value)
      this.$emit('change', value)
    }
  }
}
</script>

<style scoped>

</style>
